package cn.iocoder.yudao.module.wms.dal.mysql.rdrecord07;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.wms.controller.admin.rdrecord07.vo.Rdrecord07PageReqVO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord07.Rdrecord07DO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;

/**
 * 调拨出库主 Mapper
 *
 * @author 曾劲松
 */
@Mapper
public interface Rdrecord07Mapper extends BaseMapperX<Rdrecord07DO> {

    default PageResult<Rdrecord07DO> selectPage(Rdrecord07PageReqVO reqVO, Collection<String> personIds,
                                                Collection<String> deptIds, Collection<String> outWarehouseIds,
                                                Collection<String> inWarehouseIds, Collection<String> creator,
                                                Collection<String> auditor) {
        return selectPage(reqVO, new LambdaQueryWrapperX<Rdrecord07DO>()
                .likeIfPresent(Rdrecord07DO::getSerialNumber, reqVO.getSerialNumber())
                .inIfPresent(Rdrecord07DO::getPersonId, personIds)
                .inIfPresent(Rdrecord07DO::getDeptId, deptIds)
                .inIfPresent(Rdrecord07DO::getInWarehouseId, outWarehouseIds)
                .inIfPresent(Rdrecord07DO::getOutWarehouseId, inWarehouseIds)
                .betweenIfPresent(Rdrecord07DO::getOrderDate, reqVO.getOrderDate())
                .likeIfPresent(Rdrecord07DO::getRemark, reqVO.getRemark())
                .inIfPresent(Rdrecord07DO::getCreator, creator)
                .betweenIfPresent(Rdrecord07DO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(Rdrecord07DO::getAuditor, auditor)
                .betweenIfPresent(Rdrecord07DO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(Rdrecord07DO::getStatus, reqVO.getStatus())
                .orderByDesc(Rdrecord07DO::getId));
    }

    default Rdrecord07DO selectBySerialNumber(String serialNumber) {
        return selectOne(Rdrecord07DO::getSerialNumber, serialNumber);
    }

    default Rdrecord07DO selectByProcessInstanceId(String processInstanceId) {
        return selectOne(Rdrecord07DO::getProcessInstanceId, processInstanceId);
    }

}